package com.develope.menu.utils;

import android.util.Log;

public class Logger{

	private static final int VERBOSE = 2; 	
	private static final int ERROR = 4; 		
	private static final int WARNING = 8; 	
	private static final int INFO = 16; 		
	private static final int DEBUG = 32; 	

	public static void error(Class<?> cls, String message) {
		log(cls, ERROR, message);
	}

	public static void error(Class<?> cls, Exception e) {
		log(cls, ERROR, e.toString());
	}

	public static void verbose(Class<?> cls, String message) {
		log(cls, VERBOSE, message);
	}

	public static void verbose(Class<?> cls, Exception e) {
		log(cls, VERBOSE, e.toString());
	}
	public static void warn(Class<?> cls, String message) {
		log(cls, WARNING, message);
	}

	public static void warn(Class<?> cls, Exception e) {
		log(cls, WARNING, e.toString());
	}

	public static void info(Class<?> cls, String message) {
		log(cls, INFO, message);
	}

	public static void info(Class<?> cls, Exception e) {
		log(cls, INFO, e.toString());
	}

	public static void debug(Class<?> cls, String message) {
		log(cls, DEBUG, message);
	}

	public static void debug(Class<?> cls, Exception e) {
		log(cls, DEBUG, e.toString());
	}
	
	public static void debug(String message) {
		log(Logger.class, DEBUG, message);
	}
	
	public static void debug(String TAG, String message) {
        log(Logger.class, DEBUG, message);
    }
	
	public static void debug( Exception e) {
        log(Logger.class, DEBUG, e.toString());
    }
	
	public static void error(String message) {
		log(Logger.class, ERROR, message);
	}
	
	public static void error(String TAG, String message) {
	    log(TAG, ERROR, message);
    }

	private static void log(Class<?> cls, int level, String msg) {
		log(cls.getName(), level, msg);
	}

	private static void log(String TAG, int level, String msg) {
        if(shouldLog()) {
            switch(level) {
                case VERBOSE:
                    Log.v(TAG, msg);
                    break;
                case ERROR:
                    Log.e(TAG, msg);
                    break;
                case WARNING:
                    Log.w(TAG, msg);
                    break;
                case INFO:
                    Log.i(TAG, msg);
                    break;
                case DEBUG:
                    Log.d(TAG, msg);
                    break;
                default:
                    Log.v(TAG, msg);  
                    break;
            }
        }
    }
	
	private static boolean shouldLog() {
		return true;
	}
}